﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Log4netSample
{
    public partial class Form1 : Form
    {
        private static readonly log4net.ILog log = 
            log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            log.Debug("Application start");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            log.Info("Info start logging ");
            if (textBox1.Text == "")
            {
                log.Debug("Chua dien username");
                return;
            }
            log.Debug("truy van co so du lieu");
            Exception ex = new Exception("Co so du lie khong ton tai");
            Random rd = new Random();
            int kq = rd.Next();
            if (kq % 2 == 0)
            {
                log.Debug("Truy van thanh cong");
            }
            else
            {
                log.Debug(ex.Message);
            }
            if (textBox2.Text == "123")
            {
                log.Debug("Dien dung mat khau");
                log.Info("Info Dang nhap thanh cong");
                Close();
            }
            else
            {
                log.Debug("Sai mat khau");
            }
        }
    }
}
